package com.yunhe.servlet;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.yunhe.bean.LeavingReply;
import com.yunhe.test.test;

/**
 * Servlet implementation class ReplyMessage_Servlet
 */
@WebServlet("/ReplyDeleteModifyMessage_Servlet")
public class ReplyDeleteModifyMessage_Servlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public ReplyDeleteModifyMessage_Servlet() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		request.setCharacterEncoding("utf-8");
		response.setCharacterEncoding("utf-8");
	    if("delete".equals(request.getParameter("manage"))){
	    	if(request.getParameter("id")!=null){
				int id=Integer.decode( request.getParameter("id"));
				test te=new test();
			    te.deletem(id);					
			}
	        //页面转到商品展示页
			response.sendRedirect("ShowMessage_Servlet");
	    }
	    if("reply".equals(request.getParameter("manage"))){
			String replyContent =request.getParameter("replyContent");
			 int leavingId=0;
			 if(request.getParameter("leaving_id")!=null){
				 leavingId=Integer.decode(request.getParameter("leaving_id").trim()); 
			 }
			 System.out.println(replyContent+""+leavingId);
			 LeavingReply lr=new LeavingReply();
			 lr.setLeaving_id(leavingId);
			 lr.setReply_content(replyContent);
			 test te=new test();
			 te.replym(lr);
			 response.sendRedirect("ShowMessage_Servlet");
	    }
		if("modify".equals(request.getParameter("manage"))){
			 String replyContent =	request.getParameter("replyContent");
			 int leavingId=0;
			 if(request.getParameter("leaving_id")!=null){
				 leavingId=Integer.decode(request.getParameter("leaving_id").trim());
			 }
			 System.out.println(leavingId+""+replyContent);
			 LeavingReply lr=new LeavingReply();
			 lr.setLeaving_id(leavingId);
			 lr.setReply_content(replyContent);
			 test te=new test();
			 te.modifym(lr);
			 response.sendRedirect("ShowMessage_Servlet");	
		}
		
		
		
		
		
		
		
	
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		doGet(request, response);
	}

}
